package cn.ekuma.epos.datalogic.define.dao.crm.concerns;

import cn.ekuma.data.dao.ModifiedLogDAO;
import cn.ekuma.epos.db.table.crm.concerns.I_Concerns;
import com.openbravo.bean.crm.concerns.Concerns;

import com.openbravo.bean.CustomerCategory;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class ConcernsDAO extends ModifiedLogDAO<Concerns>{

    public ConcernsDAO(I_Session s) {
        super(s);
    }

     @Override
    public TableDefinition getTable() {
        return new TableDefinition(s,
                "CONCERNS",
                new Field[]{
                   new Field(I_Concerns.ID,Datas.STRING, Formats.STRING),
                   new Field(I_Concerns.NAME,Datas.STRING, Formats.STRING),
                   new Field(I_Concerns.PARENTID,Datas.STRING, Formats.STRING,CustomerCategory.class),
                   new Field(I_Concerns.ISHOT,Datas.BOOLEAN, Formats.BOOLEAN),
                   new Field(I_Concerns.LASTMODIFIED,Datas.TIMESTAMP, Formats.TIMESTAMP)
                } ,
                new int[]{0});
    }

    @Override
    public void writeInsertValues(DataWrite dp, Concerns obj) throws BasicException {
           dp.setString(1, obj.getID());
           dp.setString(2, obj.getName());
           dp.setString(3, obj.getM_sParentID());
           dp.setBoolean(4, obj.isHot());
           dp.setTimestamp(5,obj.getLastModified());
    }


    public Concerns readValues(DataRead dr,com.openbravo.bean.crm.concerns.Concerns obj) throws BasicException {
        if(obj==null)
        	obj=new Concerns();
        obj.setID(dr.getString(1));
        obj.setName(dr.getString(2));
        obj.setM_sParentID(dr.getString(3));
        obj.setHot(dr.getBoolean(4));
        obj.setLastModified(dr.getTimestamp(5));
        return obj;
    }

	@Override
	public Class getSuportClass() {
		return Concerns.class;
	}

}
